package com.ogilvy.audi.model;

import org.apache.struts2.json.annotations.JSON;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

/**
 * TblCircleCategory entity. @author MyEclipse Persistence Tools
 */
 @Entity
@Table(name="TBL_CIRCLE_CATEGORY")
@org.hibernate.annotations.Table(appliesTo = "TBL_CIRCLE_CATEGORY", comment = " 圈子表 ")
public class CircleCategory extends BaseObject implements java.io.Serializable {

	private Long circleId;
	private String circleName;
	private Long parentId;
	private String circleDesc;
	private String circlePic;
	private Date circleInsTime;
	private Long circleType;
	private Long sortValue;
	private Long userId;
	private Long isDisplayIndex;
	private Long isHot;
	private Long memberNum;
	private Long topicNum;
	private Long albumNum;
	private Long videoNum;
	private Long pointNum;
	private Long topicShowId;
	private Long albumShowId;
	private Long videoShowId;
	private Long userShowId;
	private Long bulletin;
	private Long isNew;
	private String circleProjectname;
    private Long compositor;
    private Integer version;
/*    private CircleCategory parent;
    private Set children = new TreeSet();
  private Set<CircleBulletin> circleBulletins=new HashSet<CircleBulletin>();
  private Set<CircleAlbum> circleAlbums=new HashSet<CircleAlbum>();
  private Set<CircleTopic> circleTopics=new HashSet<CircleTopic>();*/


	// Constructors

	/** default constructor */
	public CircleCategory() {
	}

	/** full constructor */
	public CircleCategory(String circleName,
                          String circleDesc, String circlePic, Date circleInsTime,
                          Long circleType, Long sortValue, Long userId, Long isDisplayIndex,
                          Long isHot, Long memberNum, Long topicNum, Long albumNum,
                          Long videoNum, Long pointNum, Long topicShowId, Long albumShowId,
                          Long videoShowId, Long userShowId, Long bulletin, Long isNew,
                          String circleProjectname) {
		this.circleName = circleName;

		this.circleDesc = circleDesc;
		this.circlePic = circlePic;
		this.circleInsTime = circleInsTime;
		this.circleType = circleType;
		this.sortValue = sortValue;
		this.userId = userId;
		this.isDisplayIndex = isDisplayIndex;
		this.isHot = isHot;
		this.memberNum = memberNum;
		this.topicNum = topicNum;
		this.albumNum = albumNum;
		this.videoNum = videoNum;
		this.pointNum = pointNum;
		this.topicShowId = topicShowId;
		this.albumShowId = albumShowId;
		this.videoShowId = videoShowId;
		this.userShowId = userShowId;
		this.bulletin = bulletin;
		this.isNew = isNew;
		this.circleProjectname = circleProjectname;
	}

	// Property accessors
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
	public Long getCircleId() {
		return this.circleId;
	}

	public void setCircleId(Long circleId) {
		this.circleId = circleId;
	}
       @Column(length = 200)
	public String getCircleName() {
		return this.circleName;
	}

	public void setCircleName(String circleName) {
		this.circleName = circleName;
	}
/*    @Transient
	public Long getParentId() {
        	if (this.getParent() != null) {
			return this.getParent().getCircleId();
		}
		return this.parentId;
	}*/

	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}
     @Column(length = 300)
	public String getCircleDesc() {
		return this.circleDesc;
	}

	public void setCircleDesc(String circleDesc) {
		this.circleDesc = circleDesc;
	}
  @Column(length = 300)
	public String getCirclePic() {
		return this.circlePic;
	}

	public void setCirclePic(String circlePic) {
		this.circlePic = circlePic;
	}
     @Column(length =8)
	@Temporal(value= TemporalType.TIMESTAMP)
    public Date getCircleInsTime() {
        return circleInsTime;
    }

    public void setCircleInsTime(Date circleInsTime) {
        this.circleInsTime = circleInsTime;
    }

    @Column()
    public Long getCircleType() {
		return this.circleType;
	}

	public void setCircleType(Long circleType) {
		this.circleType = circleType;
	}
       @Column()
	public Long getSortValue() {
		return this.sortValue;
	}

	public void setSortValue(Long sortValue) {
		this.sortValue = sortValue;
	}
        @Column()
	public Long getUserId() {
		return this.userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}
     @Column()
	public Long getIsDisplayIndex() {
		return this.isDisplayIndex;
	}

	public void setIsDisplayIndex(Long isDisplayIndex) {
		this.isDisplayIndex = isDisplayIndex;
	}
       @Column()
	public Long getIsHot() {
		return this.isHot;
	}

	public void setIsHot(Long isHot) {
		this.isHot = isHot;
	}
    @Column()
	public Long getMemberNum() {
		return this.memberNum;
	}

	public void setMemberNum(Long memberNum) {
		this.memberNum = memberNum;
	}
     @Column()
	public Long getTopicNum() {
		return this.topicNum;
	}

	public void setTopicNum(Long topicNum) {
		this.topicNum = topicNum;
	}
     @Column()
	public Long getAlbumNum() {
		return this.albumNum;
	}

	public void setAlbumNum(Long albumNum) {
		this.albumNum = albumNum;
	}
      @Column()
	public Long getVideoNum() {
		return this.videoNum;
	}

	public void setVideoNum(Long videoNum) {
		this.videoNum = videoNum;
	}
     @Column()
	public Long getPointNum() {
		return this.pointNum;
	}

	public void setPointNum(Long pointNum) {
		this.pointNum = pointNum;
	}
      @Column()
	public Long getTopicShowId() {
		return this.topicShowId;
	}

	public void setTopicShowId(Long topicShowId) {
		this.topicShowId = topicShowId;
	}
      @Column()
	public Long getAlbumShowId() {
		return this.albumShowId;
	}

	public void setAlbumShowId(Long albumShowId) {
		this.albumShowId = albumShowId;
	}
      @Column()
	public Long getVideoShowId() {
		return this.videoShowId;
	}

	public void setVideoShowId(Long videoShowId) {
		this.videoShowId = videoShowId;
	}
      @Column()
	public Long getUserShowId() {
		return this.userShowId;
	}

	public void setUserShowId(Long userShowId) {
		this.userShowId = userShowId;
	}
    @Column()
	public Long getBulletin() {
		return this.bulletin;
	}

	public void setBulletin(Long bulletin) {
		this.bulletin = bulletin;
	}
   @Column()
	public Long getIsNew() {
		return this.isNew;
	}

	public void setIsNew(Long isNew) {
		this.isNew = isNew;
	}
     @Column()
	public String getCircleProjectname() {
		return this.circleProjectname;
	}

	public void setCircleProjectname(String circleProjectname) {
		this.circleProjectname = circleProjectname;
	}
    @Column()
    public Long getCompositor() {
        return compositor;
    }

    public void setCompositor(Long compositor) {
        this.compositor = compositor;
    }

    @Version
    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    /*
     @ManyToOne(targetEntity=CircleCategory.class,fetch = FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.MERGE})
    @JoinColumn(name="PARENT_CATEGORY_ID")
    @ForeignKey(name="FK_CATEGORY_PARENT_ID")
    @org.hibernate.annotations.AccessType("property")
    @JSON(serialize=false)
    public CircleCategory getParent() {
        return parent;
    }


    public void setParent(CircleCategory parent) {
        this.parent = parent;
    }

    @OneToMany(mappedBy="parent",targetEntity=CircleCategory.class,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
      @OrderBy("compositor desc")
      @JSON(serialize=false)
      public Set getChildren() {
          //return nodeInfo.getChildren();
          return children;
      }

      public void setChildren(Set children) {
          //nodeInfo.setChildren(children);
          this.children = children;
      }
  @OneToMany(mappedBy = "circleCategory", fetch = FetchType.LAZY)
   // @OrderBy("chapterNum")
    @BatchSize(size=50)
    public Set<CircleBulletin> getCircleBulletins() {
        return circleBulletins;
    }

    public void setCircleBulletins(Set<CircleBulletin> circleBulletins) {
        this.circleBulletins = circleBulletins;
    }
  @OneToMany(mappedBy = "circleCategory", fetch = FetchType.LAZY)
   // @OrderBy("chapterNum")
    @BatchSize(size=50)
    public Set<CircleAlbum> getCircleAlbums() {
        return circleAlbums;
    }

    public void setCircleAlbums(Set<CircleAlbum> circleAlbums) {
        this.circleAlbums = circleAlbums;
    }

  @OneToMany(mappedBy = "circleCategory", fetch = FetchType.LAZY)
   // @OrderBy("chapterNum")
    @BatchSize(size=50)
    public Set<CircleTopic> getCircleTopics() {
        return circleTopics;
    }

    public void setCircleTopics(Set<CircleTopic> circleTopics) {
        this.circleTopics = circleTopics;
    }

    public void addChild(CircleCategory child) {
		if (child == null)
			throw new IllegalArgumentException(
					"Can't add a null node as child.");

		// Remove from old parent - one-to-many multiplicity
		if (child.getParent() != null)
			child.getParent().getChildren().remove(child);

		// Set parent in child
		child.setParent(this);

	}

	public void removeChild(CircleCategory child) {
		if (child == null)
			return;
		// Remove from parent and set parent to null
		if (child.getParent() != null)
			child.getParent().getChildren().remove(child);
		child.setParent(null);
	}
*/
    @Override
    public String toString() {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean equals(Object o) {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public int hashCode() {
        return 0;  //To change body of implemented methods use File | Settings | File Templates.
    }
}